home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEM / I-M / LineShare DEMO.sea / LineShare Scripts / EXAR Fax&ARA next >
Text File  |  1993-01-28  |  6KB  |  270 lines

  1. !
  2. ! LineShare™ Script for 2400/9600 data-fax modems (EXAR-based)
  3. ! Tested with GVC Pocket FaxModem, Best 2496 modems
  4. !
  5. ! If you want to modify this script for your modem, pay attention to
  6. ! the line marked "#### Settings ####" - it should be modified first
  7. ! This script is written to use with ARA on the "Data" subPort, so
  8. ! the modem is set to the "\N1" mode
  9. !
  10.  
  11. ! ------------------------------------------
  12. ! Resetting the modem:
  13. ! ------------------------------------------
  14. @Hangup
  15.   SetTries 2
  16.   Flush
  17.   HsReset 0,0,17,19,0,0
  18. !
  19. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  20. ! to enter the command mode
  21. !
  22. @Label 1
  23.   matchclr
  24.   matchstr 1 2 "OK\r\n"
  25.   write "ATH0&F\r"
  26.   matchread 20
  27.   Write "+++"
  28.   DtrClear
  29.   pause 10
  30.   DtrSet
  31. !
  32.   DecTries
  33.   IfTries 0 1
  34. !
  35. ! OSErr -6019 "Modem error - the modem is not responding"
  36. !
  37.   exit -6019
  38. @Label 2
  39.   write "AT+FCLASS=0\r"
  40.   Jsr 100
  41.   write "AT+FAA=0\r"
  42.   Jsr 100
  43.   exit 0
  44. ! ------------------------------------------
  45. !    Receiving incoming calls
  46. ! ------------------------------------------
  47. @ANSWER
  48. @Label 10
  49. !
  50. ! Set the modem preferred speed first
  51. !
  52.   SERRESET 2400,0,8,1
  53.   Jsr 80
  54. !
  55. ! Set the common options
  56.   Jsr 70
  57. !
  58. ! Set the communication options:
  59. ! • X4:  Extended response set
  60. ! • \N1: Direct connection (no compression, correction, speed buffering - for ARA)
  61. ! • \Q1: Xon/Xoff flow control (for Fax)
  62. ! • &S1: DSR according to CCITT (if the cable connects CTS with DSR, not DCD)
  63. !
  64. @Label 11
  65. ! #### Settings - change this according to the type of modem you have ####
  66.   Write "ATX4\\N1\\Q1&S1\r"
  67.   Jsr 100
  68. !
  69. ! Set the "work" speed
  70. !
  71. @Label 12
  72.   SERRESET 19200,0,8,1
  73.   Jsr 80
  74. !
  75. ! Set Fax parameters: LID, DCC,BOR
  76. !
  77.   Write "AT+FCLASS=2\r"
  78.   Jsr 100
  79.   Write "AT+FLID=\"Stalker_GmbH\"\r"
  80.   Jsr 100
  81.   Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
  82.   Jsr 100
  83.   Write "AT+FBOR=1\r"
  84.   Jsr 100
  85. !
  86. ! Allow modem to receive fax messages
  87. !
  88.   Write "AT+FCR=1\r"
  89.   Jsr 100
  90. !
  91. ! Tell the modem to determine the type of the incoming call
  92. ! Fetch the tube after N rings, where N has been set in the control panel (^4)
  93. !
  94.   Write "ATS0=^4+FAA=1\r"
  95.   Jsr 100
  96. !
  97. ! Everything is ready - let's sit and wait for a call
  98. ! We'll wait for 2 minutes, then reinitiate the modem
  99. !
  100. @Label 20
  101.   MatchClr
  102.   matchstr 1 20 "RING\r\n"
  103.   matchstr 2 21 "\r\nCONNECT"
  104.   matchstr 3 24 "\r\n+FCON"
  105.   matchstr 4 10 "\r\nNO "
  106.   matchstr 5 10 "\r\nBUSY"
  107.   Matchread 1200
  108.   jump 10
  109. !
  110. ! Data connection has been established (we read "CONNECT")
  111. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  112. ! if it was an incoming call, put the "RING" before the "CONNECT"
  113. !
  114. @Label 21
  115.   LogMsg "Data call…"
  116.   QueueInput "\r\nCONNECT"
  117.   ifOriginate 22
  118.   QueueInput "\r\nRING\r\n"
  119. @Label 22
  120.   Attach "Data" (DTR,Escape,TimeLimit=0)
  121. !
  122. ! Fax connection has been established (we read "+FCON")
  123. ! Put the +FCON back to the buffer,
  124. ! if it was an incoming call, put the "RING" before the "+FCON"
  125. ! Attach the "Fax" subPort
  126. !
  127. @Label 24
  128.   QueueInput "\r\n+FCON"
  129.   ifOriginate 25
  130.   QueueInput "\r\nRING\r\n"
  131. @Label 25
  132.   Attach "Fax" (DTR,RESET,ESCAPE,IDLELimit=30)
  133. ! ------------------------------------------
  134. ! Originating a call through the "Data" subport
  135. ! ------------------------------------------
  136. @ORIGINATE "Data"
  137. !
  138. ! Set the Data speed
  139. !
  140.   SERRESET 2400,0,8,1
  141.   Jsr 80
  142. !
  143. ! Set the common options
  144. !
  145.   Jsr 70
  146. !
  147. ! Set the Data mode:
  148. ! • X4:  Extended response set
  149. ! • \N1: Direct connection (no compression, correction, speed buffering - for ARA)
  150. ! • &S1: DSR according to CCITT (if the cable connects CTS with DSR, not DCD)
  151. ! • S7:  time-out (90 sec) for long-distance call (if you use them)
  152. !
  153. ! #### Settings - change this according to the type of modem you have ####
  154.   Write "ATX4\\N1&S1S7=90\r"
  155.   Jsr 100
  156. !
  157. ! Now emit all commands that the application has sent to that port
  158. ! (if we use ARA/LineShare script, no commands were sent)
  159. !
  160.   Jsr 60
  161. !
  162. ! Prepare to receive all error result codes
  163. !
  164.   Jsr 90
  165.   matchstr 1 21 "\r\nCONNECT"
  166. !
  167. ! Dial the number
  168. !
  169.   HsReset *
  170.   Write "ATD^1\r"
  171.   MatchRead 900
  172.   Write "\r"
  173.   Exit -6019
  174. ! ------------------------------------------
  175. ! Originating a call through the "Fax" subPort
  176. ! ------------------------------------------
  177. @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nNO DIALTONE\r\n")
  178. !
  179. ! Set the "Fax" speed
  180. !
  181.   SERRESET 19200,0,8,1
  182.   Jsr 80
  183. !
  184. ! Set the common options
  185. !
  186.   Jsr 70
  187. !
  188. ! Set the Fax mode
  189. ! &S0: DSR always on (see above)
  190. !
  191.   Write "AT&S0+FCLASS=2\r"
  192.   Jsr 100
  193. !
  194. ! Now emit all commands that the application has sent to that port,
  195. ! Prepare to receive all error result codes
  196. !
  197. @LABEL 50
  198.   Jsr 60
  199.   Jsr 90
  200.   MatchStr 1 24 "\r\n+FCON"
  201.   HsReset *
  202.   Write "ATD^1\r"
  203.   MatchRead 700
  204.   Write "\r"
  205.   Exit -6019
  206. !
  207. ! This section emits all modem commands sent from the client application
  208. ! For each set of commands the "OK" answer is awaited
  209. !
  210. @Label 60
  211.   EmitStart
  212. @Label 61
  213.   EmitCommand 62
  214.   Jsr 100
  215.   Jump 61
  216. @Label 62
  217.   return
  218. !
  219. ! This section initiates the modem before ANSWER and ORIGINATEs:
  220. ! factory settings + speaker control +
  221. ! reset on Dtr drop + DCD valid
  222. ! Verbal responses mode, no echo 
  223. !
  224. @Label 70
  225.   Write "ATM^2L^3&D3&C1V1E0\r"
  226.   Jsr 100
  227.   return 
  228. !
  229. ! This section syncronize the modem after the serial port speed switching
  230. !
  231. @Label 80
  232.   ChrDelay 1
  233.   Write "AT\r"
  234.   ChrDelay 0
  235.   Jsr 100
  236.   return
  237. !
  238. ! Prepare to receive error result codes
  239. !
  240. @Label 90
  241.   MatchClr
  242.   MatchStr 2 91 "NO DIALTONE\r\n"
  243.   MatchStr 3 92 "BUSY\r\n"
  244.   MatchStr 4 93 "NO CARRIER\r\n"
  245.   MatchStr 5 94 "NO ANSWER\r\n"
  246.   return
  247. @Label 91
  248.   exit -6020
  249. @Label 92
  250.   exit -6022
  251. @Label 93
  252.   exit -6021
  253. @Label 94
  254.   exit -6023
  255. !
  256. ! Processing the AT command:
  257. ! OK -> proceed
  258. ! ERROR or TimeOut ->exit -6019
  259. ! It can be called AFTER the "Write" command, since LineShare buffers input
  260. !
  261. @Label 100
  262.   MatchClr
  263.   MatchStr 1 102 "\r\nOK\r\n"
  264.   MatchStr 2 101 "\r\nERROR\r\n"
  265.   MatchRead 20
  266. @Label 101
  267.   Exit -6019
  268. @Label 102
  269.   return
  270.